import React, { useEffect } from "react";
import { connect } from "dva";
function Cinemas(props) {
  useEffect(() => {
    if (props.list.length === 0) {
      //dispatch
      console.log("页面刚打开，我还没有数据，我要去请求啦");
      props.dispatch({ type: "maizuo/getCinemaList" });
    } else {
      console.log("页面刚打开，缓存有数据呢", props.list);
    }
    console.log("useEffect中的props是：", props);
    return () => {};
  }, []);

  return (
    <div>
      {props.list.map((item) => (
        <li key={item.cinemaId}>{item.name}</li>
      ))}
    </div>
  );
}

const mapStateToProps = (model) => {
  console.log("mapStateToProps的props是：", model);
  return { list: model.maizuo.list };
};
export default connect(mapStateToProps)(Cinemas);
